package cn.stylefeng.guns.modular.erstar.controller;

import cn.stylefeng.guns.core.annotion.BusinessLog;
import cn.stylefeng.guns.core.enums.LogAnnotionOpTypeEnum;
import cn.stylefeng.guns.core.pojo.response.ResponseData;
import cn.stylefeng.guns.core.pojo.response.SuccessResponseData;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import  cn.stylefeng.guns.modular.erstar.service.ErStarService;
import  cn.stylefeng.guns.modular.erstar.model.param.ErStarParam;

import javax.annotation.Resource;

/**
 * er_star 控制器
 *
 * @author: w
 * @date: 2021/06/11 08:42
 */
@RestController
public class ErStarController {

    @Resource
    private ErStarService erStarService;

    /**
     * 分页查询er_star
     *
     * @author w
     * @date 2021/06/11 08:42
     */
    @GetMapping("/erStar/page")
    @BusinessLog(title = "er_star_分页查询", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData page(ErStarParam erStarParam) {
        return new SuccessResponseData(erStarService.page(erStarParam));
    }

    /**
     * 获取全部er_star
     *
     * @author w
     * @date 2021/06/11 08:42
     */
    @GetMapping("/erStar/list")
    @BusinessLog(title = "er_star收藏列表")
    public ResponseData list(ErStarParam erStarParam) {
        return new SuccessResponseData(erStarService.list(erStarParam));
    }

    /**
     * 查看详情er_star
     *
     * @author w
     * @date 2021/06/11 08:42
     */
    @GetMapping("/erStar/detail")
    @BusinessLog(title = "er_star_查看详情", opType = LogAnnotionOpTypeEnum.DETAIL)
    public ResponseData detail(@Validated(ErStarParam.detail.class) ErStarParam erStarParam) {
        return new SuccessResponseData(erStarService.detail(erStarParam));
    }

    /**
     * 收藏 添加、取消
     *
     * @author w
     * @date 2021/06/11 08:42
     */
    @PostMapping("/erStar/star")
    @BusinessLog(title = "收藏 添加、取消")
    public ResponseData add(@RequestBody  ErStarParam erStarParam) {

        return new SuccessResponseData(erStarService.star(erStarParam));
    }

    /**
     * 获取状态
     *
     * @author w
     * @date 2021/06/11 08:42
     */
    @PostMapping("/erStar/showStarState")
    @BusinessLog(title = "收藏状态")
    public ResponseData showStarState(@RequestBody ErStarParam erStarParam) {
        return new SuccessResponseData(erStarService.showStarState(erStarParam));
    }

    /**
     * 删除er_star
     *
     * @author w
     * @date 2021/06/11 08:42
     */
    @PostMapping("/erStar/delete")
    @BusinessLog(title = "er_star_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public ResponseData delete(@RequestBody @Validated(ErStarParam.delete.class) ErStarParam erStarParam) {
        erStarService.delete(erStarParam);
        return new SuccessResponseData();
    }

    /**
     * 编辑er_star
     *
     * @author w
     * @date 2021/06/11 08:42
     */
    @PostMapping("/erStar/edit")
    @BusinessLog(title = "er_star_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    public ResponseData edit(@RequestBody @Validated(ErStarParam.edit.class) ErStarParam erStarParam) {
        erStarService.edit(erStarParam);
        return new SuccessResponseData();
    }


}
